//
//  YKQBaseViewController.m
//  YaoKongQi
//
//  Created by ryou on 2021/5/19.
//

#import "YKQBaseViewController.h"

@interface YKQBaseViewController ()<BUNativeExpressBannerViewDelegate>
@property(nonatomic,strong)BUNativeExpressBannerView *ykqBanner;
@end

@implementation YKQBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=kWhiteColor;
    // Do any additional setup after loading the view.
}

-(void)ykqBUAdLoadBanner{
    UIWindow *window = nil;
    if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) {
        window = [[UIApplication sharedApplication].delegate window];
    }
    if (![window isKindOfClass:[UIView class]]) {
        window = [UIApplication sharedApplication].keyWindow;
    }
    if (!window) {
        window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    }
    CGFloat bottom = 0.0;
    if (@available(iOS 11.0, *)) {
        bottom = window.safeAreaInsets.bottom;
    } else {
        // Fallback on earlier versions
    }

    CGSize size = CGSizeMake(600, 90);
    // important: 升级的用户请注意，初始化方法去掉了imgSize参数
    self.ykqBanner = [[BUNativeExpressBannerView alloc] initWithSlotID:kYkqBuadBanner rootViewController:self adSize:size interval:10];
    self.ykqBanner.frame = CGRectMake(0,kYKQHeight - bottom - size.height, size.width, size.height);
    self.ykqBanner.delegate = self;
    [self.ykqBanner loadAdData];
}
- (void)nativeExpressBannerAdViewDidLoad:(BUNativeExpressBannerView *)bannerAdView{
    [self.view addSubview:self.ykqBanner];
}

- (void)nativeExpressBannerAdView:(BUNativeExpressBannerView *)bannerAdView dislikeWithReason:(NSArray<BUDislikeWords *> *)filterwords{
    [self.ykqBanner removeFromSuperview];
    self.ykqBanner = nil;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
